package com.gegao.calc;

import com.gegao.calc.operator.*;

/**
 * Created by zhangzhanzhong on 2015/12/23.
 */
public class OperatorFactory {
    private OperatorFactory() {
    }

    ;

    public static Operator getOperator(String operatorStr) throws Exception {
        Operator operator = null;
        switch (operatorStr) {
            case "+":
                operator = new Addoperator();
                break;
            case "-":
                operator = new SubOperator();
                break;
            case "*":
                operator = new MulOperator();
                break;
            case "/":
                operator = new DivOperator();
                break;
            default:
                throw new Exception("nonsupport operator:" + operatorStr);
        }
        return operator;
    }
}
